package metar_taf;

public class Location {

	private double latitude;
	private double longitude;

	public Location(double latitude, double longitude) {
		this.latitude = latitude;
		this.longitude = longitude;
	}

	public double geoDistance(Location l2) {
		int R = 6371; // km
		double lat = Math.toRadians(l2.latitude - latitude);
		double lng = Math.toRadians(l2.longitude - longitude);
		double A = Math.sin(lat / 2) * Math.sin(lat / 2)
				+ Math.cos(Math.toRadians(latitude))
				* Math.cos(Math.toRadians(l2.latitude)) * Math.sin(lng / 2)
				* Math.sin(lng / 2);
		double C = 2 * Math.atan2(Math.sqrt(A), Math.sqrt(1 - A));
		double distance = R * C;
		return distance;
	}

	public final double getLongitude() {
		return longitude;
	}

	public final void setLongitude(double longitude) {
		this.longitude = longitude;
	}

	public final double getLatitude() {
		return latitude;
	}

	public final void setLatitude(double latitude) {
		this.latitude = latitude;
	}
}
